package top.jle.wx.proxy.api.fans;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import top.jle.wx.proxy.annotation.AccessToken;
import top.jle.wx.proxy.api.ResponseBack;
import top.jle.wx.proxy.domain.fans.FansInfo;
import top.jle.wx.proxy.facade.FansFacade;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static top.jle.wx.proxy.constant.FansOption.*;
@RestController
@RequestMapping("/fans")
@Tag(name="粉丝信息API")
@AccessToken
public class FansAPI {

    @Autowired
    private FansFacade fansFacade;

    @Operation(summary = "拉取粉丝OPENID列表（同步粉丝数据的前提）")
    @GetMapping("/idList")
    public ResponseBack<FansIdListResponse> getFansIdList(@Parameter(description="拉取起始的OPENID，不传则从第一个开始拉取") @RequestParam(required = false) String nextOpenId){
        FansIdListResponse response = fansFacade.getFansIds(nextOpenId);
        return ResponseBack.success(response);
    }

    @Operation(summary = "根据粉丝OPENID获取粉丝详情")
    @GetMapping("/fansInfo")
    public ResponseBack<FansInfo> getFansInfo(@Parameter(description="粉丝OPENID") @RequestParam String openId){
        FansInfo fansInfo = fansFacade.getFansInfo(openId);
        return ResponseBack.success(fansInfo);
    }

    @Operation(summary = "根据粉丝OPENID列表批量获取粉丝详情",description = "上限100个")
    @PostMapping("/batch_fansInfo")
    public ResponseBack<List<FansInfo>> getFansInfo(@Parameter(description="粉丝OPENID列表") @RequestBody List<String> openIds){
        List<FansInfo> fansInfoList = fansFacade.batchGetFansInfo(openIds);
        return ResponseBack.success(fansInfoList);
    }

}
